﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WMS.FC.Domain.PersistenceObject.Business;
using WMS.FC.Infrastructure.Common;

namespace WMS.FC.Infrastructure.POConfig.Business
{
    public class CalibPlanEquipmentConfig : POBaseConfig<CalibPlanEquipmentPO>
    {
        public override void InitializeData(EntityTypeBuilder<CalibPlanEquipmentPO> builder)
        {
        }

        public override void MapColumn(EntityTypeBuilder<CalibPlanEquipmentPO> builder, ref int index)
        {
            builder.HasComment("工装计划表");
            builder.Property(entity => entity.CalibPlanId).ConfigColumn("CALIB_PLAN_ID", "工装计划ID").HasColumnOrder(index++);
            builder.Property(entity => entity.LineCode).ConfigColumn("LINE_CODE", "产线编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.EquipmentCode).ConfigColumn("EQUIPMENT_CODE", "设备编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.StateCode).ConfigColumn("STATE_CODE", "状态编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.WarehouseCode).ConfigColumn("WAREHOUSE_CODE", "仓库编码", 50, true).HasColumnOrder(index++);
        }

        public override void MapIndex(EntityTypeBuilder<CalibPlanEquipmentPO> builder)
        {
            builder.HasIndex(entity => new { entity.EquipmentCode, entity.WarehouseCode }).HasDatabaseName($"UN_{TableName}_1").IsUnique();
        }
    }
}
